import { accountLogin } from '@/service/account';
import { Button, Form, Input } from 'antd';
import React, { useEffect } from 'react';
import styles from './index.module.less';
const LoginForm = ()=>{
  const [form] = Form.useForm();
  const onLogin = async ()=>{
    const data =await form.validateFields()
   const res =   await accountLogin(data)
   if(res){
    // @ts-ignore
    localStorage.setItem('token',res.token)
    location.href='/'
   }
   console.log({res})
  }
  return <Form form={form} className={styles.loginWarp} labelCol={{span:4}}>
    <Form.Item label='账号' name='account'>
      <Input/>
    </Form.Item>
    <Form.Item label='密码' name='password'>
      <Input.Password/>
    </Form.Item>
    <Form.Item wrapperCol={{offset:4}}>
         <Button onClick={onLogin} type='primary' block>登陆</Button>
    </Form.Item>
  </Form>
}
function Login() {
  useEffect(() => {
    document.body.setAttribute('arco-theme', 'light');
  }, []);

  return (
    <div>
      
      <div >
        <div>
          <LoginForm />
        </div>
        <div >
          
        </div>
      </div>
    </div>
  );
}
Login.displayName = 'LoginPage';

export default Login;
